import * as echarts from 'echarts/core'
import {
	GraphicComponent,
	GridComponent,
	TitleComponent,
	TooltipComponent,
	LegendComponent,
	DataZoomComponent,
} from 'echarts/components'
import { LineChart, BarChart, PieChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'
import { UniversalTransition } from 'echarts/features'

echarts.use([
	LineChart,
	BarChart,
	PieChart,
	GraphicComponent,
	GridComponent,
	TitleComponent,
	TooltipComponent,
	LegendComponent,
	DataZoomComponent,
	CanvasRenderer,
	UniversalTransition,
])

const draw = (dome, option) => {
	const chart = echarts.init(dome)
	chart.clear()
	chart.setOption(option)
	return chart
}

export default { ...echarts, draw }
